﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows.Input;

namespace WPF_StepBar_Demo
{
    public class MainWindowViewModel : INotifyPropertyChanged
    {
        private int _stepIndex = 0;
        public int StepIndex
        {
            get => _stepIndex;
            set
            {
                _stepIndex = value;
                OnPropertyChanged(nameof(StepIndex));
            }
        }

        public List<string> strings { get; set; } = new List<string>() { "面1", "面2", "面3", "面4", "面5", "面6" };
        public List<string> Strings { get; set; } = new List<string>() { "测量1", "测量2", "测量3", "测量4", "测量5", "测量6", "测量7", "测量8", "测量9", "测量10", "测量11", "测量12" };

        public ICommand NextStepCommand { get; }

        public ICommand FontStepCommand { get; }

        public MainWindowViewModel()
        {
            NextStepCommand = new RelayCommand(NextStep, CanExecuteNextStep);
            FontStepCommand = new RelayCommand(FontStep, CanExecuteFontStep);
        }

        private bool CanExecuteFontStep()
        {
            return StepIndex >= 0;
        }

        private void FontStep()
        {
            StepIndex--;
        }

        private void NextStep()
        {
            StepIndex++;
        }
        private bool CanExecuteNextStep()
        {
            return StepIndex <= strings.Count - 1;
        }



        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
